#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.61])
AC_INIT([libfake437], [0.1], [endgame.dos@gmail.com])
AM_INIT_AUTOMAKE([-Wall -Werror no-dist-gzip dist-bzip2])
AC_CONFIG_SRCDIR([src/libfake437/fake437.h])
AC_CONFIG_HEADER([config.h])
AC_USE_SYSTEM_EXTENSIONS

AC_ARG_WITH([pkg-config-dir],
            [AS_HELP_STRING([--with-pkg-config-dir=DIR],
                            [Put fake437.pc in DIR @<:@LIBDIR/pkgconfig@:>@])],
            [pkgconfigdir=$withval],
            [pkgconfigdir=$libdir/pkgconfig])
AC_SUBST([pkgconfigdir])

# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

# Checks for libraries.
AM_PATH_SDL([1.2.11], [], [AC_MSG_ERROR([SDL is required to build.])])
AC_CACHE_CHECK([for SDL library path flags],
               [f437_cv_LIB_SDLPATH],
               [f437_cv_LIB_SDLPATH=""
                for token in `$SDL_CONFIG --libs`; do
                  case $token in
                  -L*) f437_cv_LIB_SDLPATH="$f437_cv_LIB_SDLPATH $token";;
                  esac
                done
                if test -z "$f437_cv_LIB_SDLPATH"; then
                  f437_cv_LIB_SDLPATH="none needed"
                fi])
if test "$f437_cv_LIB_SDLPATH" != "none needed"; then
  SDL_LIBPATH="$f437_cv_LIB_SDLPATH"
fi
AC_SUBST([SDL_LIBPATH])

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_FUNC_MALLOC
AC_TYPE_SIZE_T

# Checks for library functions.
AC_REPLACE_FUNCS([strdup])

AC_CONFIG_FILES([fake437.pc])
AC_CONFIG_FILES([src/charedit/charedit.1])
AC_CONFIG_FILES([Makefile
                 example/Makefile
                 src/Makefile
                 src/charedit/Makefile
                 src/libfake437/Makefile])
AC_OUTPUT
